<!-- components/navigation/PermissionWrapper.vue -->
<template>
  <div v-if="hasPermission">
    <slot />
  </div>
</template>

<script setup lang="ts">
// @ts-nocheck
import { computed } from 'vue'
import { useAppStore } from '@/stores/appStore'

const props = defineProps<{
  requiresAdmin?: boolean
}>()

const appStore = useAppStore()

const hasPermission = computed(() => {
  // 如果需要管理员权限但用户不是管理员，则无权限
  if (props.requiresAdmin && !appStore.user?.isAdmin) {
    console.log('权限不足，需要管理员权限但用户不是管理员')
    return false
  }
  
  // 默认有权限
  console.log('用户具有权限')
  return true
})
</script>